/*
 * Copyright (C) 2008 The Android Open Source Project
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/** @defgroup wchar Wchar
 * @ingroup libc
 */

#ifndef _WCHAR_H_
#define _WCHAR_H_

#include <sys/cdefs.h>
#include <stdio.h>

#include <stdarg.h>
#include <stddef.h>
#include <time.h>
#include <xlocale.h>

#include <bits/wchar_limits.h>

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */


typedef __WINT_TYPE__  wint_t;
typedef struct {
  uint8_t __seq[4];
#ifdef __LP64__
  char __reserved[4];
#endif
} mbstate_t;

enum {
    WC_TYPE_INVALID = 0,
    WC_TYPE_ALNUM,
    WC_TYPE_ALPHA,
    WC_TYPE_BLANK,
    WC_TYPE_CNTRL,
    WC_TYPE_DIGIT,
    WC_TYPE_GRAPH,
    WC_TYPE_LOWER,
    WC_TYPE_PRINT,
    WC_TYPE_PUNCT,
    WC_TYPE_SPACE,
    WC_TYPE_UPPER,
    WC_TYPE_XDIGIT,
    WC_TYPE_MAX
};

typedef long wctype_t;

#define  WEOF        ((wint_t)(-1))
/**
* @ingroup  wchar
*
* @par Description:
* The btowc() function converts single byte to wide character.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The btowc() function shall return WEOF if c has the value EOF or if c
* does not constitute a valid character in the initial shift state. Otherwise, it shall
* return the wide-character representation of that character.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see wctob
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            btowc(int c);
extern int               fwprintf(FILE *, const wchar_t *, ...);
extern int               fwscanf(FILE *, const wchar_t *, ...);
/**
* @ingroup  wchar
*
* @par Description:
* The iswalnum() function tests whether wc is  an alphanumeric wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswalnum() function shall return non-zero if wc is an alphanumeric
* wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isalnum | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswalnum(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswalpha() function tests whether wc is an alphabetic wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswalpha() function shall return non-zero if wc is an alphabetic
* wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isalpha | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswalpha(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswblank() function tests whether wc is a blank wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswblank() function shall return non-zero if wc is a
* blank wide-character code; otherwise, they shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isblank | iswctyp
* @since Huawei LiteOS V100R001C00
*/
extern int               iswblank(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswcntrl() function tests whether wc is a control wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswcntrl() function shall return non-zero if c is a
* control wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  iscntrl | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswcntrl(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswdigit() function tests whether wc is a decimal digit wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswdigit() function shall return non-zero if wc is
* a decimal digit wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isdigit | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswdigit(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswgraph() function tests whether wc is a visible wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswgraph() function shall return non-zero if wc is
* a wide-character code with a visible representation; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isgraph | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswgraph(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswlower() function tests whether wc is a lowercase letter wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswlower() function shall return non-zero if wc is a
* lowercase letter wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  islower | iswctype
| towlower
* @since Huawei LiteOS V100R001C00
*/
extern int               iswlower(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswprint() function tests whether wc is a printable wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswprint() function shall return non-zero if wc
* is a printable wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isprint
| iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswprint(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswpunct() function tests whether wc is a punctuation wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswpunct() function shall return non-zero if wc
* is a punctuation wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  ispunct | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswpunct(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswspace() function tests whether wc is a white-space wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswspace() function shall return non-zero if
* wc is a white-space wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see isspace | iswctype
* @since Huawei LiteOS V100R001C00
*/
extern int               iswspace(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswupper() function tests whether wc is an uppercase letter wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswupper() function shall return non-zero if wc
* is an uppercase letter wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  isupper | iswctype | towupper
* @since Huawei LiteOS V100R001C00
*/
extern int               iswupper(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The iswxdigit() function tests whether wc is a hexadecimal digit wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswxdigit() function shall return non-zero if wc is a hexadecimal
* digit wide-character code; otherwise, it shall return 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  iswctype | isxdigit
* @since Huawei LiteOS V100R001C00
*/
extern int               iswxdigit(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* If wc is a wide character having the character property designated by char_class,
* the iswctype() function returns nonzero. Otherwise, it returns zero.
* If wc is WEOF, zero is returned. char_class must be a character property
* descriptor returned by the wctype() function.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The iswctype() function returns nonzero if the wc has
* the designated property.  Otherwise, it returns 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  iswctype | isxdigit
* @since Huawei LiteOS V100R001C00
*/
extern int               iswctype(wint_t wc, wctype_t char_class);
/**
* @ingroup  wchar
*
* @par Description:
* The fgetwc() function reads a wide character from stream and returns it.
* If the end of stream is reached, it returns WEOF. If a wide-character
* conversion error occurs, it sets errno to EILSEQ and returns WEOF.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The fgetwc() function returns the next wide-character from the stream,
* or WEOF. In the event of an error, errno is set to indicate the cause.
*
* @par Errors
<ul>
* <li><b>ENOMEM</b>: Insufficient storage space is available.</li>
* <li><b>EILSEQ</b>: The data obtained from the input stream does not form a valid character.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fputwc | ungetwc
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            fgetwc(FILE *fp);
extern wchar_t          *fgetws(wchar_t *, int, FILE *);
/**
* @ingroup  wchar
*
* @par Description:
* The fputwc() function writes the wide character wc to stream. If a wide-character
* conversion error occurs, it sets errno to EILSEQ and returns WEOF.
* Otherwise, it returns wc.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The fputwc() function returns wc if no error occurred, or WEOF
* to indicate an error. In the event of an error, errno is set to indicate the cause.
*
* @par Errors
* <ul>
* <li><b>ENOMEM</b>: Insufficient storage space is available.</li>
* <li><b>EILSEQ</b>: Conversion of wc to the stream's encoding fails.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fgetwc
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            fputwc(wchar_t wc, FILE *fp);
extern int               fputws(const wchar_t *, FILE *);
extern int               fwide(FILE *, int);
/**
* @ingroup  wchar
*
* @par Description:
* The getwc() function identically to fgetwc().
*
* @attention
* <ul>
* <li>Refer to fgetwc().</li>
* </ul>
*
* @retval #wint_t The getwc() function returns the next wide-character from the
* stream, or WEOF. In the event of an error, errno is set to indicate the cause.
*
* @par Errors
<ul>
* <li><b>ENOMEM</b>: Insufficient storage space is available.</li>
* <li><b>EILSEQ</b>: The data obtained from the input stream does not form a valid character.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fputwc | ungetwc
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            getwc(FILE *fp);
extern wint_t            getwchar(void);
/**
* @ingroup  wchar
*
* @par Description:
* The mbsinit() function determines conversion object status.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The mbsinit() returns nonzero if *ps is an initial state, or if ps is NULL.
* Otherwise, it returns 0.
*
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbrlen
| mbrtowc
 | wcrtomb | mbsrtowcs | wcsrtombs
* @since Huawei LiteOS V100R001C00
*/
extern int               mbsinit(const mbstate_t* ps);
/**
* @ingroup  wchar
*
* @par Description:
* If s is not a null pointer, mbrlen() shall determine the number of bytes constituting
* the character pointed to by s. It shall be equivalent:\n
*           mbstate_t internal;\n
*           mbrtowc(NULL, s, n, ps != NULL ? ps : &internal);\n
* If ps is a null pointer, the mbrlen() function shall use its own
* internal mbstate_t object, which is initialized at program start-up to the initial
* conversion state. Otherwise, the mbstate_t object pointed to by ps shall be used to
* completely describe the current conversion state of the associated character sequence.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The mbrlen() function returns the number of bytes parsed
* from the multibyte sequence starting at s, if a non-null wide character was
* recognized. It returns 0, if a null wide character was recognized. It returns (size_t) -1
* and sets errno to EILSEQ, if an invalid multibyte sequence was encountered.
* It returns (size_t) -2 if it couldn't parse a complete multibyte character,
* meaning that n should be increased.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbrtowc
* @since Huawei LiteOS V100R001C00
*/
extern size_t            mbrlen(const char * __restrict s, size_t n, mbstate_t * __restrict ps);
/**
* @ingroup  wchar
*
* @par Description:
* The mbrtowc() function converts a character to a wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The mbrtowc() function returns the number of bytes parsed
* from the multibyte sequence starting at s, if a non-L'\0' wide character
* was recognized. It returns 0, if a L'\0' wide character was recognized.
* It returns (size_t) -1 and sets errno to EILSEQ, if an invalid multibyte
* sequence was encountered. It returns (size_t) -2 if it couldn't parse a
* complete multibyte character, meaning that n should be increased.
*
* @par Errors
<ul>
* <li><b>EILSEQ</b>: An invalid character sequence is detected.</li>
* <li><b>EINVAL</b>: ps points to an object that contains an invalid conversion state.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbsinit | mbsrtowcs
* @since Huawei LiteOS V100R001C00
*/
extern size_t            mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* ps);
/**
* @ingroup  wchar
*
* @par Description:
* The mbsrtowcs() function converts a character string to a wide-character string.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The mbsrtowcs() function returns the number of wide characters that
* make up the converted part of the wide-character string, not including the terminating null
* wide character. If an invalid multibyte sequence was encountered, (size_t)-1 is returned,
* and errno set to EILSEQ.
*
* @par Errors
<ul>
* <li><b>EILSEQ</b>: An invalid character sequence is detected.</li>
* <li><b>EINVAL</b>: ps points to an object that contains an invalid conversion state.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbrtowc | mbsinit | mbsnrtowcs
* @since Huawei LiteOS V100R001C00
*/
extern size_t mbsrtowcs(wchar_t* dst, const char** src, size_t len, mbstate_t* ps);
/**
* @ingroup  wchar
*
* @par Description:
* The mbsnrtowcs() function converts a character string to a wide-character string.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The mbsnrtowcs() function returns the number of wide characters that
* make up the converted part of the wide-character string, not including the terminating null
* wide character. If an invalid multibyte sequence was encountered, (size_t)-1 is returned,
* and errno set to EILSEQ.
*
* @par Errors
<ul>
* <li><b>EILSEQ</b>: An invalid character sequence is detected.</li>
* <li><b>EINVAL</b>: ps points to an object that contains an invalid conversion state.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbrtowc | mbsinit | mbsrtowcs
* @since Huawei LiteOS V100R001C00
*/
extern size_t mbsnrtowcs(wchar_t* dst, const char** src, size_t nmc, size_t len, mbstate_t* ps);
extern size_t            mbstowcs(wchar_t *, const char *, size_t);
/**
* @ingroup  wchar
*
* @par Description:
* The putwc() function identically to fputwc().
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The putwc() function returns wc if no error occurred,
* or WEOF to indicate an error. In the event of an error, errno is set
* to indicate the cause.
*
* @par Errors
<ul>
* <li><b>ENOMEM</b>: Insufficient storage space is available.</li>
* <li><b>EILSEQ</b>: Conversion of wc to the stream's encoding fails.</li>
* </ul>
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fgetwc
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            putwc(wchar_t wc, FILE *fp);
extern wint_t            putwchar(wchar_t);
/**
* @ingroup  wchar
*
* @par Description:
* The swprintf() functione prints formatted wide-character output.
*
* @attention
* <ul>
* <li>Liteos do not support the function.</li>
* </ul>
*
* @retval #int The swprintf() function returns the number of wide characters written,
* excluding the terminating null wide character.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see printf
* @since Huawei LiteOS V100R001C00
*/
extern int               swprintf(wchar_t *s, size_t n, const wchar_t *fmt, ...);
extern int               swscanf(const wchar_t *, const wchar_t *, ...);
/**
* @ingroup  wchar
*
* @par Description:
* The towlower() function transliterates uppercase wide-character code to lowercase.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The towlower() function returns the lowercase letter corresponding
* to the argument passed; otherwise, it shall return the argument unchanged.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  iswlower | towupper
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            towlower(wint_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The towupper() function transliterates lowercase wide-character code to uppercase.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The towupper() function shall return the uppercase letter corresponding
* to the argument passed. Otherwise, it shall return the argument unchanged.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see  iswupper | towlower
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            towupper(wint_t);
/**
* @ingroup  wchar
*
* @par Description:
* The ungetwc() function is the wide-character equivalent of the ungetc() function.
* It pushes back a wide character onto stream and returns it. If wc is WEOF, it returns WEOF.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wint_t The ungetwc() function returns wc when successful, or WEOF upon failure.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fgetwc
* @since Huawei LiteOS V100R001C00
*/
extern wint_t            ungetwc(wint_t wc, FILE *fp);
/**
* @ingroup  wchar
*
* @par Description:
* The vfwprintf() function performs wide-character output to stream.
* stream must not be byte oriented.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The vfwprintf() function returns the number of wide characters written,
* excluding the terminating null wide character. It returns -1 when an error occurs.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fprintf | fputwc | printf | snprintf
* @since Huawei LiteOS V100R001C00
*/
extern int vfwprintf(FILE* fp, const wchar_t* fmt0, va_list ap);

extern int vfwscanf(FILE*, const wchar_t*, va_list);
/**
* @ingroup  wchar
*
* @par Description:
* The vswprintf() function performs wide-character output to an array of wide characters.
* The programmer must ensure that there is room for at least n wide characters at s.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The vswprintf() function returns the number of wide characters written,
* excluding the terminating null wide character. It returns -1 when an error occurs.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see fprintf | fputwc | | printf | snprintf
* @since Huawei LiteOS V100R001C00
*/
extern int vswprintf(wchar_t* s, size_t n, const wchar_t* fmt, va_list ap);
extern int vswscanf(const wchar_t*, const wchar_t*, va_list);
extern int vwprintf(const wchar_t*, va_list);
extern int vwscanf(const wchar_t*, va_list);
extern wchar_t* wcpcpy (wchar_t*, const wchar_t *);
extern wchar_t* wcpncpy (wchar_t*, const wchar_t *, size_t);
/**
* @ingroup  wchar
*
* @par Description:
* The wcrtomb() function converts a wide-character code to a character.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The wcrtomb() function returns the number of bytes that have been or
* would have been written to the byte array at s. If wc can not be represented as a multibyte
* sequence (according to the current locale), (size_t) -1 is returned, and errno set to EILSEQ.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbsinit | wcsrtombs
* @since Huawei LiteOS V100R001C00
*/
extern size_t            wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
extern int               wcscasecmp(const wchar_t *, const wchar_t *);
extern int               wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
extern wchar_t          *wcscat(wchar_t *, const wchar_t *);
/**
* @ingroup  wchar
*
* @par Description:
* The wcschr() function searches the first occurrence of c in the
* wide-character string pointed to by s.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wchar_t* The wcschr() function returns a pointer to the first occurrence of c in
* the wide-character string pointed to by s, or NULL if wc does not  occur in the string.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see strchr | wmemchr
* @since Huawei LiteOS V100R001C00
*/
extern wchar_t          *wcschr(const wchar_t *s, wchar_t c);
/**
* @ingroup  wchar
*
* @par Description:
* The wcscmp() function compares the wide-character string pointed to by s1
* and the wide-character string pointed to by s2.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The wcscmp() function returns zero if the wide-character strings
* at s1 and s2 are equal. It returns an integer greater than zero if at the first
* differing position i, the corresponding wide-character s1[i] is greater than s2[i].
* It returns an integer less than zero if at the first differing position i,
* the corresponding wide-character s1[i] is less than s2[i].
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see strcmp | wmemcmp
* @since Huawei LiteOS V100R001C00
*/
extern int               wcscmp(const wchar_t *s1, const wchar_t *s2);
/**
* @ingroup  wchar
*
* @par Description:
* The wcscoll() function shall compare the wide-character string pointed to by
* s1 to the wide-character string pointed to by s2.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int Upon successful completion, wcscoll() shall return an integer
* greater than, equal to, or less than 0, according to whether the wide-character
* string pointed to by s1 is greater than, equal to, or less than the wide-character
* string pointed to by s2.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see wcscmp | wcsxfrm
* @since Huawei LiteOS V100R001C00
*/
extern int               wcscoll(const wchar_t *s1, const wchar_t *s2);
extern wchar_t          *wcscpy(wchar_t *, const wchar_t *);
extern size_t            wcscspn(const wchar_t *, const wchar_t *);
/**
* @ingroup  wchar
*
* @par Description:
* The wcsftime() function converts date and time to a wide-character string.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t If the total number of resulting wide-character codes
* including the terminating null wide-character code is no more than maxsize,
* wcsftime() shall return the number of wide-character codes placed into the
* array pointed to by s, not including the terminating null wide-character code.
* Otherwise, zero is returned and the contents of the array are unspecified.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see strftime
* @since Huawei LiteOS V100R001C00
*/
extern size_t            wcsftime(wchar_t *__restrict s, size_t maxsize,
    const wchar_t *__restrict format, const struct tm *__restrict t) __LIBC_ABI_PUBLIC__;
/**
* @ingroup  wchar
*
* @par Description:
* The wcslen() function shall compute the number of wide-character
* codes in the wide-character string to which s points,
* not including the terminating null wide-character code.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The wcslen() function shall return the length of s.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see strlen
* @since Huawei LiteOS V100R001C00
*/
extern size_t            wcslen(const wchar_t *s);
extern int               wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
extern int               wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
extern wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t);
/**
* @ingroup  wchar
*
* @par Description:
* The wcsncmp() function compares the wide-character string pointed to by s1
* and the wide-character string pointed to by s2, but at most n wide characters
* from each string. In each string, the comparison extends only up to the first
* occurrence of a null wide character (L"\0"), if any.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The wcsncmp() function returns zero if the wide-character
* strings at s1 and s2, truncated to at most length n,
* are equal. It returns an integer greater than zero if at the first differing
* position i (i < n), the corresponding wide-character
* s1[i] is greater than s2[i]. It returns an integer less than zero if at the
* first differing position i (i < n), the corresponding
* wide-character s1[i] is less than s2[i].
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see strncmp
* @since Huawei LiteOS V100R001C00
*/
extern int               wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
/**
* @ingroup  wchar
*
* @par Description:
* The wcsncpy() function copies at most n wide characters from the wide-character
* string pointed to by src, including the terminating null wide character (L"\0"),
* to the array pointed to by dest. Exactly n wide characters are written at dst.
* If the length wcslen(src) is smaller than n, the remaining wide characters in the
* array pointed to by dst are filled with null wide characters. If the length
* wcslen(src) is greater than or equal to n, the string pointed to by dest will
* not be terminated by a null wide character. The strings may not overlap.The programmer
* must ensure that there is room for at least n wide characters at dst.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wchar_t* wcsncpy() returns the address of dst.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see strncpy
* @since Huawei LiteOS V100R001C00
*/
extern wchar_t          *wcsncpy(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t n);
/**
* @ingroup  wchar
*
* @par Description:
* The wcsnrtombs() function converts a wide-character string to a multibyte string.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The wcsnrtombs() function returns the number of bytes that make up
* the converted part of multibyte sequence, not including the terminating null byte.
* If a wide character was encountered which could not be converted, (size_t) -1
* is returned, and errno set to EILSEQ.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbsinit | wcsrtombs
* @since Huawei LiteOS V100R001C00
*/
extern size_t wcsnrtombs(char* dst, const wchar_t** src, size_t nwc, size_t len, mbstate_t* ps);
extern wchar_t          *wcspbrk(const wchar_t *, const wchar_t *);
extern wchar_t          *wcsrchr(const wchar_t *, wchar_t);
/**
* @ingroup  wchar
*
* @par Description:
* The wcsrtombs() function convert a wide-character string to a multibyte string.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #size_t The wcsrtombs() function returns the number of bytes that make up
* the converted part of multibyte sequence, not including the terminating null byte.
* If a wide character was encountered which could not be converted, (size_t) -1
* is returned, and errno set to EILSEQ.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see mbsinit | wcrtomb | wcsnrtombs | wcstombs
* @since Huawei LiteOS V100R001C00
*/
extern size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* ps);
extern size_t            wcsspn(const wchar_t *, const wchar_t *);
extern wchar_t          *wcsstr(const wchar_t *, const wchar_t *);
extern double wcstod(const wchar_t*, wchar_t**);
extern float wcstof(const wchar_t*, wchar_t**);
extern wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);
extern long wcstol(const wchar_t*, wchar_t**, int);
extern long long wcstoll(const wchar_t*, wchar_t**, int);
extern long double wcstold(const wchar_t*, wchar_t**);
extern unsigned long wcstoul(const wchar_t*, wchar_t**, int);
extern unsigned long long wcstoull(const wchar_t*, wchar_t**, int);
extern int               wcswidth(const wchar_t *, size_t);
/**
* @ingroup  wchar
*
* @par Description:
* The wcsxfrm() function transforms wide-character string.
*
* @attention
* <ul>
* <li>On error, it don't set errno in Liteos.</li>
* </ul>
*
* @retval #size_t The wcsxfrm() shall return the length of the transformed
* wide-character string (not including the terminating null wide-character code).
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see wcscmp | wcscoll
* @since Huawei LiteOS V100R001C00
*/
extern size_t            wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n);
/**
* @ingroup  wchar
*
* @par Description:
* The wctob() function tests whether the multibyte representation of
* the wide character c, starting in the initial state, consists of a
* single byte. If so, it is returned as an unsigned char.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The wctob() function returns the single-byte representation of c,
* if it exists, of EOF otherwise.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see btowc
| wcrtomb | wctomb
* @since Huawei LiteOS V100R001C00
*/
extern int               wctob(wint_t c);
/**
* @ingroup  wchar
*
* @par Description:
* The wctype_t type represents a property which a wide character may or may not have.
* In other words, it represents a class of wide characters. This type's nature is
* implementation-dependent, but the special value (wctype_t) 0 denotes
* an invalid property. The wctype() function returns a property, given by its name.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wctype_t The wctype() function returns a property descriptor if the name is valid.
* Otherwise, it returns (wctype_t) 0.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see iswctype
* @since Huawei LiteOS V100R001C00
*/
extern wctype_t          wctype(const char *property);
extern int               wcwidth(wchar_t wc);
/**
* @ingroup  wchar
*
* @par Description:
* The wmemchr() searches the n wide characters starting at s for the
* first occurrence of the wide character c.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wchar_t* The wmemchr() function returns a pointer to the first occurrence of c among
* the n wide characters starting at s, or NULL if c does not occur among these.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see memchr | wcschr
* @since Huawei LiteOS V100R001C00
*/
extern wchar_t          *wmemchr(const wchar_t *s, wchar_t c, size_t n);
/**
* @ingroup  wchar
*
* @par Description:
* The wmemcmp() function compares the n wide-characters starting at s1
* and the n wide-characters starting at s2.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #int The wmemcmp() function returns zero if the wide-character arrays
* of size n at s1 and s2 are equal. It returns an integer greater than zero if
* at the first  differing position  i (i < n), the corresponding wide-character
* s1[i] is greater than s2[i]. It returns an integer less than zero if at the first
* differing position i (i < n), the corresponding wide-character s1[i] is less than s2[i].
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see memcmp | wcscmp
* @since Huawei LiteOS V100R001C00
*/
extern int               wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);
/**
* @ingroup  wchar
*
* @par Description:
* The wmemcpy() function copies n wide characters from the array starting at
* s to the array starting at d. The programmer must ensure that there is room
* for at least n wide characters at d.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wchar_t* wmemcpy() returns the address of d.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see memcpy | wmemmove
* @since Huawei LiteOS V100R001C00
*/
extern wchar_t          *wmemcpy(wchar_t * __restrict d, const wchar_t * __restrict s, size_t n);
#if defined(__USE_GNU)
extern wchar_t          *wmempcpy(wchar_t *, const wchar_t *, size_t);
#endif
/**
* @ingroup  wchar
*
* @par Description:
* The wmemmove() function is the wide-character equivalent of the memmove() function.
* It copies n wide characters from the array starting at src to the array starting at dest.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wchar_t* wmemmove() returns dest.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see memmove | wmemcpy
* @since Huawei LiteOS V100R001C00
*/
extern wchar_t          *wmemmove(wchar_t *dest, const wchar_t *src, size_t n);
/**
* @ingroup  wchar
*
* @par Description:
* The wmemset() function fills the array of n wide-characters
* starting at s with n copies of the wide character c.
*
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @retval #wchar_t wmemset() returns the address of s.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see memset
* @since Huawei LiteOS V100R001C00
*/
extern wchar_t          *wmemset(wchar_t *s, wchar_t c, size_t n);
extern int               wprintf(const wchar_t *, ...);
extern int               wscanf(const wchar_t *, ...);

extern long long          wcstoll_l(const wchar_t *, wchar_t **, int, locale_t);
extern unsigned long long wcstoull_l(const wchar_t *, wchar_t **, int, locale_t);
extern long double        wcstold_l(const wchar_t *, wchar_t **, locale_t );

extern int    wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
extern size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);

extern size_t wcslcat(wchar_t*, const wchar_t*, size_t);
/**
* @ingroup  wchar
*
* @par Description:
* The wcslcpy() function copies src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns wcslen(src); if retval >= siz, truncation occurred.
*
* @attention
* <ul>
* <li>The wcslcpy() function is not a standard C Library Function.</li>
* </ul>
*
* @retval #size_t Returns wcslen(src); if retval >= siz, truncation occurred.
*
* @par Dependency:
* <ul><li>wchar.h</li></ul>
* @see wcsxfrm
* @since Huawei LiteOS V100R001C00
*/
extern size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz);

typedef void *wctrans_t;
extern wint_t towctrans(wint_t, wctrans_t);
extern wctrans_t wctrans(const char*);

#if __POSIX_VISIBLE >= 200809
FILE* open_wmemstream(wchar_t**, size_t*);
wchar_t* wcsdup(const wchar_t*);
size_t wcsnlen(const wchar_t*, size_t);
#endif


#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

#endif /* _WCHAR_H_ */
